package com.hzhc.controller.stockPlan;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzhc.annotation.SysTemLog;
import com.hzhc.entity.CntrStockPlan;
import com.hzhc.entity.TowInfo;
import com.hzhc.enumBean.ResultUtilCodeEnum;
import com.hzhc.service.CntrStockPlanService;
import com.hzhc.utils.ResultUtil;
import com.hzhc.utils.TokenUtil;
import com.hzhc.vo.CntrStockPlanVo;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.hzhc.common.BaseController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * <p>
 * 堆存计划 前端控制器
 * </p>
 *
 * @author 功不唐捐
 * @since 2025-04-10
 */
@RestController
@RequestMapping("/cntrStockPlan")
@RequiredArgsConstructor
public class CntrStockPlanController extends BaseController {

    private final CntrStockPlanService cntrStockPlanService;

    @RequestMapping("/getPlanList")
    public ResultUtil<List<CntrStockPlanVo>> getPlanList(HttpServletRequest request,@RequestBody CntrStockPlanVo vo) {
        Page<CntrStockPlanVo> page = new Page<>(vo.getPageIndex(), vo.getPageSize());
        List<CntrStockPlanVo> list = cntrStockPlanService.getList(vo,page);
        return ResultUtil.build(list,page.getTotal(),page.getPages(), ResultUtilCodeEnum.SUCCESS);

    }
    @PostMapping("/addYardPlan")
    public ResultUtil<T> addYardPlan(HttpServletRequest request, @RequestBody CntrStockPlan plan){

        Long userID = TokenUtil.getUserID(request);
        plan.setUserId(userID);
        return cntrStockPlanService.addYardPlan(plan);
    }


    /**
     * 修改有效状态
     */
    @PostMapping("/changeValid")
    public ResultUtil<T> changeValid(@RequestBody CntrStockPlan plan){
        return cntrStockPlanService.changeValid(plan);
    }

}
